const https = require("https");
const fs = require("fs");

https.get(
  "https://www.jd.com/?cu=true&utm_source=baidu-pinzhuan&utm_medium=cpc&utm_campaign=t_288551095_baidupinzhuan&utm_term=0f3d30c8dba7459bb52f2eb5eba8ac7d_0_177095f8e6dc4c8c913e1a394929728e",
  (res) => {
    let result = "";
    // 监听接收到信息
    // 一次只能监听一小段内容
    res.on("data", (chunk) => {
      result += chunk;
    });
    // 监听结束
    res.on("end", () => {
      fs.writeFile("./jd.html", result, (err) => {
        if (err) throw err;
        console.log("京东");
      });
    });
  }
);
